from sqlalchemy import Column, Integer, String, ForeignKey, Table, Date, DateTime
from sqlalchemy.orm import relationship
from .__basemodel__ import Model
import uuid
from datetime import datetime

# ondelete为CASCADE时，其外键关联的表记录被删除时，此记录也被删除，这样就可以直接使用query.delete()方法了。


class Video(Model):
    '''用户表'''

    __tablename__ = 'video'

    id = Column(String(36), default=lambda: str(uuid.uuid4()), primary_key=True)
    user_id = Column(String(50), ForeignKey('dota_functioneer.id', ondelete='CASCADE'))
    title = Column(String(200))
    cover_address = Column(String(2000))
    duration = Column(String(10))
    video_address = Column(String(2000))
    video_flash_address = Column(String(2000))
    src_video_id = Column(String(50))
    src_video_id_encryption = Column(String(100))
    publish_date = Column(Date)
